package com.example.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

/**
 * Created by Jack on 2017/6/17.
 */
public class CustomValidater implements Validator {

    Logger logger = LoggerFactory.getLogger(CustomValidater.class);

    @Override
    public boolean supports(Class<?> aClass) {

        return true;
    }

    @Override
    public void validate(Object o, Errors errors) {
        logger.info("o----------->{}", o);
        if (o instanceof User) {
            User user = (User) o;
            user.setId("2");
        }

    }
}
